﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using YFTFunction;
using System.Data.SqlClient;
using System.Data;
using YFTOpenAPI;
using YFTOpenAPI.Model;
using YY.Model;
using System.Security.Cryptography;
using System.Text;
using System.IO;
using WebRequestHelp = BaseFunction.WebRequestHelp;

namespace YY.financial_information
{
    /// <summary>
    /// FinanceHandler 的摘要说明
    /// </summary>
    public class FinanceHandler : BaseFunction.LoginHelp, IHttpHandler, IRequiresSessionState
    {
        string key = ConfigurationManager.AppSettings["MerchantNumber"].ToString();
        string ip= ConfigurationManager.AppSettings["ip"];
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string action = context.Request["action"].ToString();
            string userid = base.GetSessionModel().user_guid+"";
            switch (action)
            {
                case "GetTopSixRecord":
                    //获取交易记录的前6条
                    context.Response.Write(GetTopSixRecord(userid, action));
                    break;
                case "GetTradeRecordByPage":
                    //分页获取交易记录
                    int page = BaseFunction.RequestValidate.GetFormInt("page", 1);   //当前页码
                    int rows = BaseFunction.RequestValidate.GetFormInt("rows", 10);   //每页显示多少条
                    string StartTime = BaseFunction.RequestValidate.GetFormString("StartTime", DateTime.Now.AddMonths(1).ToString());//开始时间
                    string EndTime = BaseFunction.RequestValidate.GetFormString("EndTime", DateTime.Now.ToString());//结束时间
                    string Status = BaseFunction.RequestValidate.GetFormString("Status", "1");   //交易记录的状态 默认成功
                    string today = BaseFunction.RequestValidate.GetFormString("today", "");
                    string week = BaseFunction.RequestValidate.GetFormString("week", "");
                    string month = BaseFunction.RequestValidate.GetFormString("month", "");
                    string threemonth = BaseFunction.RequestValidate.GetFormString("threemonth", "");
                    string type = BaseFunction.RequestValidate.GetFormString("type", "");
                    context.Response.Write(GetTradeRecordByPage(userid, page, rows, StartTime, EndTime, Status, action, today, week, month, threemonth, type));
                    break;
                case "GetTradeRecordCountByPage":
                    //分页获取交易记录的总条数
                    string _StartTime = BaseFunction.RequestValidate.GetFormString("StartTime", DateTime.Now.AddMonths(1).ToString());//开始时间
                    string _EndTime = BaseFunction.RequestValidate.GetFormString("EndTime", DateTime.Now.ToString());//结束时间
                    string _Status = BaseFunction.RequestValidate.GetFormString("Status", "1");   //交易记录的状态 默认成功
                    int _rows = BaseFunction.RequestValidate.GetFormInt("rows", 10);   //每页显示多少条
                    string _today = BaseFunction.RequestValidate.GetFormString("today", "");
                    string _week = BaseFunction.RequestValidate.GetFormString("week", "");
                    string _month = BaseFunction.RequestValidate.GetFormString("month", "");
                    string _threemonth = BaseFunction.RequestValidate.GetFormString("threemonth", "");
                    string _type = BaseFunction.RequestValidate.GetFormString("type", "");
                    context.Response.Write(GetTradeRecordCountByPage(userid, _StartTime, _EndTime, _Status, action, _rows, _today, _week, _month, _threemonth, _type));
                    break;
                case "SearchAllBank":
                    //查询银行信息列表
                    context.Response.Write(SearchAllBank());
                    break;
                case "BankAccount":
                    //根据用户编号获得 其绑定的银行卡信息
                    context.Response.Write(BankAccount(userid));
                    break;
                case "GetAllTradeType":
                    //获取所有交易类别
                    context.Response.Write(GetAllTradeType());
                    break;
                case "UnbundBankAccount":
                    //解绑银行卡
                    string id = BaseFunction.RequestValidate.GetFormString("id", "");//主键
                    context.Response.Write(UnbundBankAccount(id));
                    break;
                case "SendSMSCode":
                    //发送短信验证
                    string phonenumber = BaseFunction.RequestValidate.GetFormString("phonenumber", "");//手机号码
                    if (phonenumber == "")
                    {
                        context.Response.Write(SendSMSCode(userid, true));
                    }
                    else
                    {
                        context.Response.Write(SendSMSCode(phonenumber));
                    }
                    break;
                case "CheckTradePassword":
                    //检查交易密码是否正确
                    string tradepassword = BaseFunction.RequestValidate.GetFormString("tradepassword", "");//交易密码
                    context.Response.Write(CheckTradePassword(tradepassword, userid));
                    break;
                case "ApplyWithdrawCash":
                    //申请提现
                    string _BankCardNo = BaseFunction.RequestValidate.GetFormString("BankCardNo", "");
                    string ArrivalAccountDateType = BaseFunction.RequestValidate.GetFormString("ArrivalAccountDateType", "");
                    string cash = BaseFunction.RequestValidate.GetFormString("cash", "");
                    string BankCardId = BaseFunction.RequestValidate.GetFormString("BankCardId", "");
                    context.Response.Write(ApplyWithdrawCash(_BankCardNo, ArrivalAccountDateType, cash, userid, BankCardId));
                    break;
                case "CheckCode":
                    //检查交易短信验证码是否正确
                    string smscode = BaseFunction.RequestValidate.GetFormString("smscode", "");
                    context.Response.Write(CheckCode(smscode));
                    break;
                case "CheckCodeToWithdraw":
                    //检查申请提现短信验证码是否正确
                    string _smscode = BaseFunction.RequestValidate.GetFormString("smscode", "");
                    context.Response.Write(CheckCode(_smscode, true));
                    break;
                case "GetPaymentMethod":
                    //查询支付方式
                    context.Response.Write(GetPaymentMethod());
                    break;
            }
        }


        public string GetPaymentMethod()
        {
            string sqlstr = " TypeKey = 'PaymentMethod'";
            DataTable dt = BaseFunction.StaticTableClass.DataDictionaryHelp.bll_DataDictionary.GetList(sqlstr).Tables[0];
            string result = JsonConvert.SerializeObject(dt);
            return result;
        }


        public string CheckCode(string smscode)
        {
            if (Session["SMS"] != null)
            {
                string code = Session["SMS"].ToString().Split(',')[0];
                if (smscode == code)
                {
                    return "1";
                }
                else
                {
                    return "0";
                }
            }
            else
            {
                return "0";
            }
        }

        public string CheckCode(string smscode,bool flag)
        {
            if (Session["smsinfor"] != null)
            {
                string code = Session["smsinfor"].ToString().Split(',')[0];
                if (smscode == code)
                {
                    return "1";
                }
                else
                {
                    return "0";
                }
            }
            else
            {
                return "0";
            }
        }

        /// <summary>
        /// 提现申请
        /// </summary>
        public int ApplyWithdrawCash(string _BankCardNo, string ArrivalAccountDateType, string cash, string userid, string BankCardId)
        {
            YY.Model.WithdrawCashApplyInfor model = new WithdrawCashApplyInfor();
            model.ApplyDate = DateTime.Now;
            model.ArrivalAccountDateType = Convert.ToInt32(ArrivalAccountDateType);
            model.BankCardNo = _BankCardNo;
            model.BankCardId = BankCardId;
            model.UserId = userid;
            model.Status = 0;
            model.Cash = decimal.Parse(cash);
            return BaseFunction.StaticTableClass.WithdrawCashApplyInforHelp.bll_WithdrawCashApplyInfor.Add(model);
        }

        /// <summary>
        /// 检测交易密码
        /// </summary>
        public string CheckTradePassword(string tradepassword, string userid)
        {
            string ResInfor = "";
            string epwd = BaseFunction.MD5Helper.GetMD5String(tradepassword);
            string sqlstr = " user_guid= '" + userid + "'";
            DataTable dt = BaseFunction.StaticTableClass.agent_users_Help.bll_agent_users.GetList(sqlstr).Tables[0];
            if (dt.Rows.Count > 0)
            {
                string amount = dt.Rows[0]["amount"].ToString();
                //通过银富通账号 调用接口（获取支付密码） 调用接口
                //解密字符串，获取铭文秘钥
                string UserInfoID = amount;//银富通账号
                string PayPassword = epwd;//支付密码
                YFTOpenAPI.TransactionAPI openapi = new YFTOpenAPI.TransactionAPI(key, ip, "27CAC2A3-F0C1-449C-8D59-62A9A263E48C");
                YFTOpenAPI.Model.ResponseData responseData = openapi.CheckPayPassword(UserInfoID, PayPassword);
                if (responseData.statuscode == 1)
                {
                    //支付密码正确
                    ResInfor = "1";
                }
                else
                {
                    //错误信息
                    string message = responseData.message;
                    ResInfor = "0";
                }
            }
            return ResInfor;
        }

        private string SendSMSCode(string userid, bool Flag)
        {
            string phonenumber = BaseFunction.StaticTableClass.agent_users_Help.bll_agent_users.GetList(" id = '" + userid + "'").Tables[0].Rows[0]["PhoneNumberOne"].ToString();
            Random rad = new Random();//实例化随机数产生器rad；
            string value = rad.Next(100000, 1000000).ToString();//用rad生成大于等于100000，小于等于999999的随机数；
            string MessageInfor = "尊敬的用户,您提现的验证码是：" + value + ".验证时间为60秒,请尽快完成验证；请勿向任何人提供您收到的短信校验码。";
            string status = "success";
            int flag = 1;
            if (Session["smsinfor"] != null)
            {
                string infor = Session["smsinfor"].ToString().Split(',')[1];
                if (DateTime.Parse(infor).AddMinutes(1).CompareTo(DateTime.Now) < 0)
                {
                    if (!BaseFunction.CommonClass.SendMessage(phonenumber, MessageInfor))
                    {
                        status = "fail";
                        flag = 0;
                    }
                    else
                    {
                        Session["smsinfor"] = value + "," + DateTime.Now;
                    }
                }
            }
            else
            {
                if (!BaseFunction.CommonClass.SendMessage(phonenumber, MessageInfor))
                {
                    status = "fail";
                    flag = 0;
                }
                else
                {
                    Session["smsinfor"] = value + "," + DateTime.Now;
                }
            }
            AddSms(phonenumber, "获取提现的验证码", flag);
            return value + "_" + status + "_" + phonenumber.Substring(0, 3) + "****" + phonenumber.Substring(7, 4);
        }

        private string SendSMSCode(string phonenumber)
        {
            Random rad = new Random();//实例化随机数产生器rad；
            string value = rad.Next(100000, 1000000).ToString();//用rad生成大于等于100000，小于等于999999的随机数；
            string MessageInfor = "尊敬的用户,您绑定银行卡的验证码是：" + value + ".验证时间为60秒,请尽快完成验证；请勿向任何人提供您收到的短信校验码。";
            string status = "";
            int flag = 1;
            if (Session["SMS"] != null)
            {
                string infor = Session["SMS"].ToString().Split(',')[1];
                if (DateTime.Parse(infor).AddMinutes(1).CompareTo(DateTime.Now) < 0)
                {
                    if (!BaseFunction.CommonClass.SendMessage(phonenumber, MessageInfor))
                    {
                        status = "fail";
                        flag = 0;
                    }
                    else
                    {
                        Session["SMS"] = value + "," + DateTime.Now;
                    }
                }
            }
            else
            {
                if (!BaseFunction.CommonClass.SendMessage(phonenumber, MessageInfor))
                {
                    status = "fail";
                    flag = 0;
                }
                else
                {
                    Session["SMS"] = value + "," + DateTime.Now;
                }
            }
            AddSms(phonenumber, "获取绑定银行卡验证码", flag);
            return value + status;
        }

        /// <summary>
        /// 插入短信信息表
        /// </summary>
        /// <param name="phonenumber">手机号码</param>
        /// <param name="content">发送内容</param>
        /// <param name="issuccess">发送是否成功</param>
        public void AddSms(string phonenumber, string content, int issuccess)
        {
            YY.Model.SmsInfor model = new Model.SmsInfor();
            model.SendTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
            model.SendContent = content;
            model.PhoneNumber = phonenumber;
            model.IfSuccess = issuccess;
            BaseFunction.StaticTableClass.SmsInforHelp.bll_SmsInfor.Add(model);
        }

        /// <summary>
        /// 解绑银行卡账号
        /// </summary>
        public string UnbundBankAccount(string id)
        {
            if (BaseFunction.StaticTableClass.YiyangBankUserInforHelp.bll_YiyangBankUserInfor.Delete(Convert.ToInt32(id)))
            {
                return "1";
            }
            else
            {
                return "0";
            }
        }

        /// <summary>
        /// 获取所有的交易类型
        /// </summary>
        /// <returns></returns>
        public string GetAllTradeType()
        {
            string sqlstr = " TypeKey = 'JYFL'";
            DataTable dt = BaseFunction.StaticTableClass.DataDictionaryHelp.bll_DataDictionary.GetList(sqlstr).Tables[0];
            string result = JsonConvert.SerializeObject(dt);
            return result;
        }

        //根据交易编号获得交易名称
        public string GetTradeTypeNameById(string id)
        {
            string result = "";
            string sqlstr = " ID = '" + id + "'";
            DataTable dt = BaseFunction.StaticTableClass.DataDictionaryHelp.bll_DataDictionary.GetList(sqlstr).Tables[0];
            if (dt.Rows.Count > 0)
            {
                result = dt.Rows[0]["DataName"].ToString();
            }
            else
            {
                result = "";
            }
            return result;
        }

        /// <summary>
        /// 获取交易记录的前6条
        /// </summary>
        public string GetTopSixRecord(string GUID, string action)
        {
            string eguid = OpenAPI.EncryptPar(GUID);
            string eaction = OpenAPI.EncryptPar(action);
            string Ip = BaseFunction.StaticTableClass.SystemConfigHelp.GetSystemConfigValue("YFT_IP");
            //生成Md5校验码    (所有参数加密后相加)
            //范例:string Md5 = OpenAPI.MD5Encrypt("加密后参数1"+"加密后参数2"+"加密后参数3", "yiyang");
            string Md5 = OpenAPI.MD5Encrypt(eguid + eaction, key);
            string result = WebRequestHelp.PostDataToUrl("eguid=" + eguid + "&key=" + key + "&action=" + eaction + "&md5=" + Md5, Ip + "/HTTP/GetTradeInfor.aspx");
            List<YiyangTradeInfor> _list = JsonConvert.DeserializeObject<List<YiyangTradeInfor>>(result);
            foreach (YiyangTradeInfor model in _list)
            {
                model.Type = GetTradeTypeNameById(model.Type);
                model.TradeTime = model.TradeTime;//yyyy-MM-dd
                model.ID = Encode(model.ID+"", "yiyanglelaozu");
            }
            result = JsonConvert.SerializeObject(_list);
            return result;
        }

        public static int Encode(string str, string key)
        {

            DESCryptoServiceProvider provider = new DESCryptoServiceProvider();

            provider.Key = Encoding.ASCII.GetBytes(key.Substring(0, 8));

            provider.IV = Encoding.ASCII.GetBytes(key.Substring(0, 8));

            byte[] bytes = Encoding.UTF8.GetBytes(str);

            MemoryStream stream = new MemoryStream();

            CryptoStream stream2 = new CryptoStream(stream, provider.CreateEncryptor(), CryptoStreamMode.Write);

            stream2.Write(bytes, 0, bytes.Length);

            stream2.FlushFinalBlock();

            StringBuilder builder = new StringBuilder();

            foreach (byte num in stream.ToArray())
            {

                builder.AppendFormat("{0:X2}", num);

            }

            stream.Close();

            return Convert.ToInt32(builder);

        }

        /// <summary>
        /// 根据用户编号获得 其绑定的银行卡信息
        /// </summary>
        public string BankAccount(string userid)
        {
            string sql = " select BankCardType,DataIcon,PhoneNumber,DataName as BankName,a.ID as ID, BankId, UseId,true_name as TrueName, OpenAccountAddress, AccountBranch, BankCardNo, IsDefaultCard,ReservePhonenumber, QuickPayment,BandTime from ";
            sql += " tb_YiyangBankUserInfor a join tb_DataDictionary b on a.BankId = b.ID";
            sql += " join tb_agent_users on a.UseId = tb_agent_users.user_guid ";
            sql += " where UseId = '" + userid + "' order by BandTime desc ";
            DataTable dt = ChangeDataSource(BaseFunction.StaticTableClass.YiyangBankUserInforHelp.Query(sql)).Tables[0];
            string result = JsonConvert.SerializeObject(dt);
            return result;
        }

        public DataSet ChangeDataSource(DataSet dssource)
        {
            DataSet ds = new DataSet();
            DataTable dt = new DataTable("ds");
            dt.Columns.Add(new DataColumn("BankCardType", typeof(string)));
            dt.Columns.Add(new DataColumn("DataIcon", typeof(string)));
            dt.Columns.Add(new DataColumn("PhoneNumber", typeof(string)));
            dt.Columns.Add(new DataColumn("BankName", typeof(string)));
            dt.Columns.Add(new DataColumn("ID", typeof(string)));
            dt.Columns.Add(new DataColumn("BankId", typeof(string)));
            dt.Columns.Add(new DataColumn("UseId", typeof(string)));
            dt.Columns.Add(new DataColumn("TrueName", typeof(string)));
            dt.Columns.Add(new DataColumn("OpenAccountAddress", typeof(string)));
            dt.Columns.Add(new DataColumn("AccountBranch", typeof(string)));
            dt.Columns.Add(new DataColumn("BankCardNo", typeof(string)));
            dt.Columns.Add(new DataColumn("BankCardNo2", typeof(string)));
            dt.Columns.Add(new DataColumn("IsDefaultCard", typeof(string)));
            dt.Columns.Add(new DataColumn("ReservePhonenumber", typeof(string)));
            dt.Columns.Add(new DataColumn("QuickPayment", typeof(string)));
            dt.Columns.Add(new DataColumn("BandTime", typeof(string)));
            foreach (DataRow dr in dssource.Tables[0].Rows)
            {
                DataRow newdr = dt.NewRow();
                newdr["BankCardType"] = dr["BankCardType"].ToString() == "1" ? "储蓄卡" : "信用卡"; 
                newdr["DataIcon"] = dr["DataIcon"];
                newdr["PhoneNumber"] = dr["PhoneNumber"];
                newdr["BankName"] = dr["BankName"];
                newdr["ID"] = dr["ID"];
                newdr["BankId"] = dr["BankId"];
                newdr["UseId"] = dr["UseId"].ToString();
                newdr["TrueName"] = dr["TrueName"].ToString();
                newdr["OpenAccountAddress"] = dr["OpenAccountAddress"];
                newdr["AccountBranch"] = dr["AccountBranch"].ToString();
                newdr["BankCardNo"] = "**** **** ****" + dr["BankCardNo"].ToString().Substring(11, 5);
                newdr["BankCardNo2"] = dr["BankCardNo"].ToString();
                newdr["IsDefaultCard"] = dr["IsDefaultCard"];
                newdr["ReservePhonenumber"] = dr["ReservePhonenumber"].ToString().Substring(0, 3) + "****" + dr["ReservePhonenumber"].ToString().Substring(6, 5);
                newdr["QuickPayment"] = dr["QuickPayment"].ToString() == "1" ? "已开通" : "未开通";
                newdr["BandTime"] = DateTime.Parse(dr["BandTime"].ToString()).ToString("yyyy年MM月dd日");
                dt.Rows.Add(newdr);
            }
            ds.Tables.Add(dt);
            return ds;
        }


        /// <summary>
        /// 查询银行信息列表
        /// </summary>
        public string SearchAllBank()
        {
            string sqlstr = " TypeKey = 'BankCard'";
            DataTable dt = BaseFunction.StaticTableClass.DataDictionaryHelp.bll_DataDictionary.GetList(sqlstr).Tables[0];
            string result = JsonConvert.SerializeObject(dt);
            return result;
        }

        /// <summary>
        /// 分页获取交易记录
        /// </summary>
        public string GetTradeRecordByPage(string GUID, int page, int rows, string StartTime, string EndTime, string Status, string action, string today, string week, string month, string threemonth, string type)
        {
            string Ip = BaseFunction.StaticTableClass.SystemConfigHelp.GetSystemConfigValue("YFT_IP");
            if (today != "off")
            {
                StartTime = DateTime.Now.AddDays(0).ToString("yyyy-MM-dd 00:00:00");

                EndTime = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd 23:59:59");
            }
            if (week != "off")
            {
                StartTime = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd 00:00:00");
                EndTime = DateTime.Now.AddDays(0).ToString("yyyy-MM-dd 23:59:59");
            }
            if (month != "off")
            {
                StartTime = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd 00:00:00");
                EndTime = DateTime.Now.AddDays(0).ToString("yyyy-MM-dd 23:59:59");
            }
            if (threemonth != "off")
            {
                StartTime = DateTime.Now.AddMonths(-3).ToString("yyyy-MM-dd 00:00:00");
                EndTime = DateTime.Now.AddDays(0).ToString("yyyy-MM-dd 23:59:59");
            }
            string eguid = OpenAPI.EncryptPar(GUID);
            string epage = OpenAPI.EncryptPar(page.ToString());
            string erows = OpenAPI.EncryptPar(rows.ToString());
            string eStartTime = OpenAPI.EncryptPar(StartTime);
            string eEndTime = OpenAPI.EncryptPar(EndTime);
            string eaction = OpenAPI.EncryptPar(action);
            string eStatus = OpenAPI.EncryptPar(Status);
            string etype = OpenAPI.EncryptPar(type);
            string Md5 = OpenAPI.MD5Encrypt(eguid + epage + erows + eStartTime + eEndTime + eStatus + eaction + etype, key);
            string result = WebRequestHelp.PostDataToUrl("eguid=" + eguid + "&key=" + key + "&epage=" + epage + "&erows=" + erows + "&eStartTime=" + eStartTime + "&eEndTime=" + eEndTime + "&eStatus=" + eStatus + "&action=" + eaction + "&etype=" + etype + "&md5=" + Md5, Ip + "/HTTP/GetTradeInfor.aspx");
            List<YiyangTradeInfor> _list = JsonConvert.DeserializeObject<List<YiyangTradeInfor>>(result);
            foreach (YiyangTradeInfor model in _list)
            {
                model.ID = Encode(model.ID+"", "yiyanglelaozu");
            }
            result = JsonConvert.SerializeObject(_list);
            return result;
        }

        /// <summary>
        /// 分页获取交易记录的总条数
        /// </summary>
        public int GetTradeRecordCountByPage(string GUID, string StartTime, string EndTime, string Status, string action, int pagesize,string today, string week, string month, string threemonth, string type)
        {
            string Ip = BaseFunction.StaticTableClass.SystemConfigHelp.GetSystemConfigValue("YFT_IP");
            if (today != "off")
            {
                StartTime = DateTime.Now.AddDays(0).ToString("yyyy-MM-dd 00:00:00");

                EndTime = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd 23:59:59");
            }
            if (week != "off")
            {
                StartTime = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd 00:00:00");
                EndTime = DateTime.Now.AddDays(0).ToString("yyyy-MM-dd 23:59:59");
            }
            if (month != "off")
            {
                StartTime = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd 00:00:00");
                EndTime = DateTime.Now.AddDays(0).ToString("yyyy-MM-dd 23:59:59");
            }
            if (threemonth != "off")
            {
                StartTime = DateTime.Now.AddMonths(-3).ToString("yyyy-MM-dd 00:00:00");
                EndTime = DateTime.Now.AddDays(0).ToString("yyyy-MM-dd 23:59:59");
            }
            int pageindexnumber = 0;
            string eguid = OpenAPI.EncryptPar(GUID);
            string eStartTime = OpenAPI.EncryptPar(StartTime);
            string eEndTime = OpenAPI.EncryptPar(EndTime);
            string eaction = OpenAPI.EncryptPar(action);
            string eStatus = OpenAPI.EncryptPar(Status);
            string etype = OpenAPI.EncryptPar(type);
            string Md5 = OpenAPI.MD5Encrypt(eguid + eStartTime + eEndTime + eStatus + eaction + etype, key);
            string result = WebRequestHelp.PostDataToUrl("eguid=" + eguid + "&key=" + key + "&eStartTime=" + eStartTime + "&eEndTime=" + eEndTime + "&eStatus=" + eStatus + "&action=" + eaction + "&etype=" + etype + "&md5=" + Md5, Ip + "/HTTP/GetTradeInfor.aspx");
            int number = Convert.ToInt32(result.Split(':')[1].Substring(0, result.Split(':')[1].Length - 2));
            if (number % pagesize == 0)
            {
                pageindexnumber = number / pagesize;
            }
            else
            {
                pageindexnumber = number / pagesize + 1;
            }
            return pageindexnumber;
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}